class Solution {
  // Write a function min that takes two arguments and returns their minimum
  min(a, b) {
    return a < b ? a : b;
  }

  /**
    Zero is even.
    One is odd.
    For any other number N, its evenness is the same as N –2.
   * @param num number
   */
  isEven(num) {
    if (num == 0) {
      return "even";
    } else if (num == 1) {
      return "odd";
    } else {
      return num < 0 ? this.isEven(-num) : this.isEven(num - 2);
    }
  }

  countB(str) {
    let result = 0;
    for (let i = 0; i < str.length; i++) {
      result += str[i] == "B" ? 1 : 0;
    }
    return result;
  }

  countChar(str) {
    return function (c) {
      let result = 0;
      for (let i = 0; i < str.length; i++) {
        result += str[i] == c ? 1 : 0;
      }
      return result;
    };
  }
}

const sol = new Solution();
console.log(sol.isEven(50));
console.log(sol.isEven(75));
console.log(sol.isEven(-1));

console.log(sol.countB("Boobie"));
console.log(sol.countChar("BooBie")("B"));
console.log(sol.countChar("char")("c"));
